﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
namespace SQT.tracnghiem.Ajax.ASP.Events
{
    public partial class send_tttn : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int event_id = int.Parse(Request.QueryString["event_id"]);
            int type = int.Parse(Request.QueryString["type"]);
            int question = int.Parse(Request.QueryString["question"]);
            int player = int.Parse(Request.QueryString["player"]);
            string answer = Request.QueryString["answer"];
            
            var get_event = new TblEventRoomController().FetchAll().Where(x => x.EventId == event_id && x.GameType == type && x.GameId == question && x.PlayerId==player);
            if (get_event.ToList().Count != 0)
            {
                new TblEventRoomController().Update(get_event.Single().Id, null, null, null, null, answer, null);
                var get_room = new TblEventDetailController().FetchAll().Where(x => x.EventId == event_id);
                if (get_room.ToList().Count != 0)
                    new TblEventDetailController().Update(get_room.Single().Id, null, null, null, 0, 3);
            }
        }
    }
}